'''
Created on Jun 6, 2009

@author: mkiyer
'''

import sys

from veggie.parser.elandparser import ElandParser
from optparse import OptionParser

if __name__ == '__main__':
    # setup command line parser
    usage = "usage: %prog [options] elandfile"
    optparser = OptionParser()
    optparser.add_option("--format", action="store", dest="format", choices=('export', 'eland_result'), default='export')
    optparser.add_option("-o", "--output",
                         metavar="FILE", help="write output to FILE (default output is to terminal)")
    
    # parse command line
    (options, args) = optparser.parse_args()
    # check options, args
    if len(args) < 1:
        optparser.error('No input file specified')
    
    # get arguments
    elandfilename = args[0]
    
    # setup output
    if options.output:
        outfile = open(options.output, 'w')
    else:
        outfile = sys.stdout
    
    ElandParser.getElandExportFileStats(open(elandfilename), outfile)